#! /bin/sh
# UCLA CS 111 - Check distribution.

export LC_ALL=C

tar xvf $1.tar.gz.tmp || exit

cd $1 || exit

old=$(ls -al | grep -v '^d') || exit
make clean || exit
new=$(ls -al | grep -v '^d') || exit

test "$old" = "$new" || {
  echo "junk in distribution"
  echo "=== old ===
$old
=== new ===
$new"
  exit 1
}

make check || exit

make clean || exit
new=$(ls -al | grep -v '^d') || exit
test "$old" = "$new" || {
  echo "'make clean' doesn't clean"
  echo "=== old ===
$old
=== new ===
$new"
  exit 1
}
